package com.yupi.yuoj.model.vo;

import com.yupi.yuoj.model.entity.Articles;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * 文章视图对象
 */
@Data
public class ArticleVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 用户ID
     */
    private Long user_id;

    /**
     * 分类ID
     */
    private Long category_id;

    /**
     * 标题
     */
    private String title;

    /**
     * 文章别名
     */
    private String slug;

    /**
     * 摘要
     */
    private String summary;

    /**
     * 浏览数
     */
    private Integer view_count;

    /**
     * 点赞数
     */
    private Integer like_count;

    /**
     * 用户昵称
     */
    private String nickname;

    /**
     * 对象转包装类
     *
     * @param article
     * @return
     */
    public static ArticleVO objToVo(Articles article) {
        if (article == null) {
            return null;
        }
        ArticleVO articleVO = new ArticleVO();
        BeanUtils.copyProperties(article, articleVO);
        return articleVO;
    }

    private static final long serialVersionUID = 1L;
}